home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group98c.txt
/
000126_icon-group-sender _Thu Dec 10 17:11:13 1998.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
4KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id RAA07859
for icon-group-addresses; Thu, 10 Dec 1998 17:10:36 -0700 (MST)
Message-Id: <199812110010.RAA07859@baskerville.CS.Arizona.EDU>
Date: Thu, 10 Dec 1998 12:43:24 -0500 (EST)
From: "R. Clayton" <clayton@cc.gatech.edu>
To: icon-group@optima.CS.Arizona.EDU
Subject: Plus, also, too.
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
I'd just like to say a few words on behalf of our forgotten friends, the
regular expressions:
ma cat re.icn
link regexp
procedure main()
local pat, cnt, l
pat := RePat("(XMULT|XZERO|YMULT|YZERO):([0-9]+\.[0-9]*E[-+][0-9]+)")
cnt := 0
while l := read() do
every ReFind(pat, l) do {
write(Re_ParenGroups[1], " is ", Re_ParenGroups[2])
cnt +:= 1
}
write("cnt = ", cnt)
end # main
ma icont -u re.icn
Translating:
re.icn:
main
No errors
Linking:
ma ./re < dat
XMULT is 1.11E-4
XMULT is 1.12E-4
XMULT is 1.13E-4
XMULT is 1.14E-4
XZERO is 4.21E-8
XZERO is 4.22E-8
XZERO is 4.23E-8
YMULT is 1.31E-6
YMULT is 1.32E-6
YMULT is 1.33E-6
YZERO is 0.41E+0
YZERO is 0.42E+0
YZERO is 0.43E+0
cnt = 13
ma
The data came from the original posting; I modified it slightly to make it
easier to see if everything was working correctly.
What everyone is missing about procedures-that-do-the-job is the speed
consideration.
Well, o.k. - let's take a look.
ma cat fi.icn
procedure main()
local numberchars, cnt, l
numberchars := (&digits ++ 'e' ++ 'E' ++ '+' ++ '-' ++ '.')
cnt := 0
while l := read() do
l ?
every tab(past("XMULT:"|"XZERO:"|"YMULT:"|"YZERO:", &subject)) do {
write(tab(many(numberchars)))
cnt +:= 1
}
write("cnt = ", cnt)
end # main
procedure past(s1, s2, i1, i2)
suspend find(s1, s2, i1, i2) + *s1
end
ma icont -u fi.icn
Translating:
fi.icn:
main
past
No errors
Linking:
ma ./fi < dat
1.11E-4
1.12E-4
1.13E-4
1.14E-4
4.21E-8
4.22E-8
4.23E-8
1.31E-6
1.32E-6
1.33E-6
0.41E+0
0.42E+0
0.43E+0
cnt = 13
ma i=0; while [ $i -lt 100 ]; do cat dat; i=`expr $i + 1`; done > dat.big
ma wc -l dat dat.big
1 dat
100 dat.big
101 total
ma time re < dat.big
cnt = 1300
real 0m2.11s
user 0m1.92s
sys 0m0.03s
ma time ./fi < dat.big
cnt = 1300
real 0m0.28s
user 0m0.13s
sys 0m0.06s
ma
Re and fi were modified to avoid printing matched values. Regular
expressions are an order of magnitude slower than the past generator on a
sun ultra 2 with 168 mhz cpus and 128 meg of main store. I don't know what
your situation is, but I'd be happy to pay the price in performance to get a
more understandable (to me) parser (I realize this wasn't the dichotomy set
up by the original poster).
Think about embedding either procedure in a deep inner loop of some kind.
Yeah, so? Either your parsing the same string over and over in a loop, in
which case procedures aren't your problem, or you're parsing a new string
every time, in which case what else are you going to do?